package com.www.ve.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 接口文档配置

 * @author XiaoJie
 * @date 2025/06/03 10:21:10
 */
@Configuration
public class SwaggerConfig {
	@Bean
	public GroupedOpenApi allApi () {
		String[] paths = {"/**"};
		String[] packagedToMatch = {"com.zzw"};
		return GroupedOpenApi.builder().group("所有接口").pathsToMatch(paths).packagesToScan(packagedToMatch).build();
	}

	@Bean
	public OpenAPI customOpenApi () {
		Contact contact = new Contact();
		contact.setName("致筑网");

		OpenAPI openAPI = new OpenAPI().info(new Info().title("放量平台").description("放量平台").contact(contact).version("2.0"));
		openAPI.addSecurityItem(new SecurityRequirement().addList("api_key")).components(new Components().addSecuritySchemes("api_key", new SecurityScheme().name("Authorization").type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER)));

		return openAPI;
	}
}
